package top.llove.code.system.monitor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.llove.common.utils.poi.ExcelUtil;
import top.llove.framework.aspectj.lang.annotation.Log;
import top.llove.framework.aspectj.lang.enums.BusinessType;
import top.llove.framework.web.controller.BaseController;
import top.llove.framework.web.domain.AjaxResult;
import top.llove.framework.web.page.TableDataInfo;
import top.llove.code.system.monitor.pojo.SysOperaLog;
import top.llove.code.system.monitor.service.YSysOperaLogService;


/**
 * 操作日志记录
 *
 * @author: 幸会
 * @date: 2021/12/4 16:03
 * @email: 1846724873@qq.com
 * @description: 操作日志记录
 * @version: 1.0
 */
@RestController
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
    @Autowired
    private YSysOperaLogService operLogService;

    @PreAuthorize("@perm.hasPermi('monitor:operlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysOperaLog operLog)
    {
        startPage();
        List<SysOperaLog> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }


    @Log(title = "操作日志", businessType = BusinessType.DELETE)
    @PreAuthorize("@perm.hasPermi('monitor:operlog:remove')")
    @DeleteMapping("/{operIds}")
    public AjaxResult remove(@PathVariable Long[] operIds)
    {
        return toAjax(operLogService.deleteOperLogByIds(operIds));
    }

    @Log(title = "操作日志", businessType = BusinessType.CLEAN)
    @PreAuthorize("@perm.hasPermi('monitor:operlog:remove')")
    @DeleteMapping("/clean")
    public AjaxResult clean()
    {
        operLogService.cleanOperLog();
        return AjaxResult.success();
    }
}
